package com.wangsh.userscenter.service.outer.implay;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wangsh.userscenter.common.service.BaseServiceImplay;
import com.wangsh.userscenter.common.util.ConstatFinalUtil;
import com.wangsh.userscenter.service.outer.IOuterService;
import com.wangsh.userscenter.service.system.api.ISystemService;
import com.wangsh.userscenter.service.system.pojo.ARegion;

/**
 * 外部调用接口
 * 
 * @author wangsh_sxt
 *
 */
@Service
public class OuterServiceImplay extends BaseServiceImplay implements IOuterService
{
	@Autowired
	private ISystemService systemService;
	
	@Override
	public JSONObject regionList01Service(JSONObject reqJSON)
	{
		JSONObject resultJSON = new JSONObject();
		JSONObject dataResJSON = new JSONObject(); 
		
		/* 解析上行信息 */
		JSONObject dataReqJSON = reqJSON.getJSONObject("data");
		
		String parentId = dataReqJSON.getString("parentId");
		/* 查询数据 */
		Map<String, Object> condMap = new HashMap<String,Object>();
		condMap.put("parentId", parentId);
		List<ARegion> regionList = this.systemService.findCondListRegionService(null, condMap);
		JSONArray regionArr = new JSONArray();
		for (Iterator<ARegion> iterator = regionList.iterator(); iterator.hasNext();)
		{
			ARegion region = (ARegion) iterator.next();
			regionArr.add(region.getJson());
		}
		
		dataResJSON.put("regionList", regionArr);
		resultJSON.put("data", dataResJSON);
		resultJSON.put("code", "0");
		resultJSON.put("info", ConstatFinalUtil.INFO_JSON.get("0"));
		return resultJSON;
	}

}
